package com.lab02.spring.firstpage.services;

import com.lab02.spring.firstpage.models.Reservation;
import com.lab02.spring.firstpage.persistence.ReservationDao;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: bsceran
 * Date: 5/23/13
 * Time: 2:31 PM
 * To change this template use File | Settings | File Templates.
 */
public class ReservationServiceImpl implements  ReservationService {
    private ReservationDao reservationDao;

    public void setReservationDao(ReservationDao reservationDao) {
        this.reservationDao = reservationDao;
    }

    @Override
    public List<Reservation> query(String courtName) {
        List<Reservation> result = new ArrayList<Reservation>();
        for(Reservation reservation : reservationDao.findAll()) {
            if(courtName.equals(reservation.getCourtName())) {
                result.add(reservation);
            }
        }
        return result;
    }
}
